package com.weixing.mall.provider.controller.front;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.weixing.mall.base.wrapper.Result;
import com.weixing.mall.base.wrapper.ResultUtil;
import com.weixing.mall.provider.model.domain.Depot;
import com.weixing.mall.provider.service.IDepotService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("api/depotRPC")
@Api(value = "前端：活动商品模块仓库信息Api",tags = "前端：活动商品模块仓库信息")
public class FrontDepotController {

    @Autowired
    private IDepotService iDepotService;
    //根据ID获取仓库信息。
    @GetMapping("getEntityById")
    @ApiOperation(value = "根据仓库ID获取仓库信息")
    public Result getEntityById(Long depotId){
        return ResultUtil.success(iDepotService.getById(depotId));
    }
    //根据ID获取仓库信息。
    @GetMapping("getListByIdArray")
    @ApiOperation(value = "使用活动所属仓库信息ID查询活动所属仓库信息")
    public Result getListByIdArray(String  depotId){
        String []  tmp=depotId.split("_");
        List<Depot> tt=new ArrayList<Depot>();
        for(int i=0;i<tmp.length;i++){
            tt.add(iDepotService.getById(Long.valueOf(tmp[i])));
        }
        return ResultUtil.success(tt);
    }
    @GetMapping("getAll")
    @ApiOperation(value = "适用于新增活动仓库列表")
    public Result getAll(){
        return ResultUtil.success(iDepotService.list(new QueryWrapper<Depot>().eq("is_commodity",1)));
    }
}
